#include "common.h"
#include "configtable.h"
#include "dataloader.h"
#include "scheduler.h"
#include "outputer.h"
#include <iostream>

#ifdef SUBMIT
#define datadir "/data"
#define outfile "/output/solution.txt"
#else
#define datadir "/home/singularity/test/2022HUAWEI/SDK/SDK_C++/data"
#define outfile "/home/singularity/test/2022HUAWEI/SDK/SDK_C++/output/solution.txt"
#endif

int main() {
    // 载入配置表
    Configtable config(datadir);

    //创建执行流程中的各个模块
    Dataloader dataloader(datadir);
    Scheduler scheduler(config);
    Outputer outputer(outfile);

    //开始循环载入数据执行
    while (true) {
        demands demands_in;
        allocs allocs_out;
        if (dataloader.load(demands_in)) {
            scheduler.schedule(config, demands_in, allocs_out);
            outputer.output(allocs_out);
        } else {
            break;
        }
    }
	return 0;
}
